dodefs() {

  ###----------------------------------------
  _setattr() {
    [ $# -ne 3 ] && return
    local ledfile=/sys/class/leds/$1/$2
    [ -f ${ledfile} ] && echo ${3} >${ledfile}
  }
  led_on() {
    {
      _setattr $1 trigger none
      _setattr $1 brightness 255
    } 2>/dev/null
  }
  led_off() {
    {
      _setattr $1 trigger none
      _setattr $1 brightness 0
    } 2>/dev/null
  }
  led_blink() {
    {
      _setattr $1 trigger timer
      _setattr $1 delay_on ${2:-500}
      _setattr $1 delay_off ${3:-500}
    } 2>/dev/null
  }
  led_blink_fast() {
    led_blink $1 100 100
  }
  led_blink_slow() {
    led_blink $1 1000 1000
  }
  ###----------------------------------------
  CACHED_MDMINFO=/etc/wwan_mdm_info.cache
  if [ X1 = X$(awk '{if ($1 < 120) {print 1}}' /proc/uptime) ]; then
    rm -f $CACHED_MDMINFO /dev/ttyCTL
  fi 2>/dev/null
  _has_mdm() {
    case ${1} in
      "") echo 0 ;;
      *:*) lsusb | grep -c ${1} ;;
    esac
  }
  _get_atc() {
    cd /sys/bus/usb-serial/devices
    command ls -d1 ttyUSB* 2>/dev/null | sort -t_ -k2,2n -V | awk 'NR=='${1}' {printf $0}'
  }

  _tmp_atc=$(_get_atc 3)
  {
    if [ $(_has_mdm 2c7c:) -eq 1 ]; then
      _sbtype='Q4G'
      _tmp_atc=$(_get_atc 3)
      [ X1 = X$(_has_mdm 2c7c:0900) ] && _sbtype='Q5G'
      echo 'MDMTYPE='${_sbtype}
      echo 'MDMVENDOR=QUECTEL'
      echo 'LUALTECMD=/usr/sbin/lte_quectel'
    elif [ X1 = X$(_has_mdm 2cb7:) ] || [ X1 = X$(_has_mdm 1508:) ]; then
      _sbtype='F4G'
      [ X1 = X$(_has_mdm 2cb7:) ] && _sbtype='F5G'
      echo 'MDMTYPE='${_sbtype}
      echo 'MDMVENDOR=FIBOCOM'
      echo 'LUALTECMD=/usr/sbin/lte_fibocom'
    else #if [ X1 = X$(_has_mdm 19d2:) ]; then
      echo 'MDMTYPE=G4G'
      echo 'MDMVENDOR=GOSUNCN'
      echo 'LUALTECMD=/usr/sbin/lte_gosuncn'
    fi
    echo "MDMATC=${_tmp_atc}"
    echo 'ATSNDER=/usr/sbin/hclatcmd'
  } >${CACHED_MDMINFO}
  sync
  ###load-cached-vars
  . ${CACHED_MDMINFO}
  [ ! -e /dev/ttyCTL ] && [ ${#MDMATC} -ge 1 ] && ln -s -f /dev/${MDMATC} /dev/ttyCTL
}

dodefs
unset -f dodefs
